package com.opencloud.ywt.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.opencloud.common.model.PageParams;
import com.opencloud.ywt.client.model.entity.BhyfCity;
import com.opencloud.ywt.client.model.entity.BhyfProvince;
import com.opencloud.ywt.provider.mapper.BhyfCityMapper;
import com.opencloud.ywt.provider.service.BhyfCityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 动量服务
 * @author yeyong
 */

@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class BhyfCityServiceImpl implements BhyfCityService {
    @Autowired
    private BhyfCityMapper bhyfCityMapper;

    @Override
    public IPage<BhyfCity> findListPage(PageParams pageParams) {
        BhyfCity query = pageParams.mapToObject(BhyfCity.class);
        QueryWrapper<BhyfCity> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().orderByDesc(BhyfCity::getCityId);
        return bhyfCityMapper.selectPage(new Page(pageParams.getPage(), pageParams.getLimit()), queryWrapper);
    }

    @Override
    public List<BhyfProvince> getProvince(){
        return bhyfCityMapper.getBhyfProvinceList();
    }
}